package org.example.account.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.account.mapper.AccountTblMapper;
import org.example.account.model.AccountTbl;
import org.example.account.service.AccountTblService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountTblServiceImpl extends ServiceImpl<AccountTblMapper, AccountTbl>
        implements AccountTblService{

    @Autowired
    private AccountTblMapper accountTblMapper;


    @Override
    @Transactional
    public void updateByAccountId(Integer accountId, Integer money) {
        AccountTbl accountTbl = accountTblMapper.selectById(accountId);
        int currentMoney = accountTbl.getMoney() - money;
        accountTblMapper.updateMoneyById(accountId, currentMoney);
        System.out.println("用户执行结束");
    }
}
